//
//  CZStatusCell.swift
//  iOSWeibo10
//
//  Created by 李伟鹏 on 16/5/15.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class CZStatusCell: UITableViewCell {
    var status: CZStatus?{
        didSet{
            originalView.status = status
            retweetView.retweetStatus = status?.retweeted_status
        }
    }
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
         prepareUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func prepareUI(){
        contentView.addSubview(originalView)
        contentView.addSubview(retweetView)
        contentView.addSubview(bottomView)
        
        originalView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(contentView).offset(10)
            make.leading.trailing.equalTo(contentView)
            
        }
        
        retweetView.snp_makeConstraints { (make) -> Void in
            make.leading.trailing.equalTo(contentView)
            make.top.equalTo(originalView.snp_bottom)
//            make.height.equalTo(50)
        }
        
        bottomView.snp_makeConstraints { (make) -> Void in
            make.leading.equalTo(contentView)
            make.top.equalTo(retweetView.snp_bottom)
            make.trailing.equalTo(contentView)
            make.height.equalTo(37)
        }
        
        contentView.snp_makeConstraints { (make) -> Void in
            make.leading.equalTo(self)
            make.top.equalTo(self)
            make.trailing.equalTo(self)
            make.bottom.equalTo(bottomView)
        }
    }
    
    private lazy var originalView:CZStatusOriginalView = CZStatusOriginalView()
    
    private lazy var retweetView: CZStatusRetweetView = CZStatusRetweetView()
    
     private lazy var bottomView: CZStatusBottomView = CZStatusBottomView()
}
